test(node-integration): Retry RabbitMQ connect in amqplib scenario#21062
Merged
Conversation
JPeer264
approved these changes
May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
connectToRabbitMQ()insuites/tracing/amqplib/scenario.mjswith a 5-attempt, 1-second-backoff retry loop. First attempt is unchanged; only retries trigger on connect rejection.Root cause
From the failing run:
The docker-compose healthcheck (
rabbitmq-diagnostics -q ping) reports the broker ready before its AMQP listener can complete the protocol handshake. So:await amqp.connect(AMQP_URL)rejects withSocket closed abruptly during opening handshake.OnUnhandledRejectionintegration captures it → Sentry sends it as an error envelope.utils/runner.ts:509) sees aneventwhere it expected atransactionand throws.Fix
Add a retry loop around
amqp.connect+createChannel. The first attempt path is unchanged (no extra latency in the common case). On transient connection rejection, retry up to 4 more times with 1 s spacing — total worst-case extra time 4 s, well within the test's 60 s timeout. After 5 failures, throwslastError(same failure mode as today, just delayed).Connection retry is the industry-standard pattern for broker-readiness races where the healthcheck reports a coarser signal than the actual protocol. The change is purely additive — first-attempt success is unchanged, assertions are unchanged, and a truly broken broker still surfaces as a scenario failure.
Fixes #20969
🤖 Generated with Claude Code